/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package conceitos.componentes;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
import javax.swing.ButtonModel;
import javax.swing.JButton;

/**
 *
 * @author jeferson
 */
public class ButtonVideo extends JButton {
    
    private Color color1 = new Color(255,0,0);
    private Color color2 = new Color(255,151,0);
    private Color borda = new Color(0,0,0);
    
    public ButtonVideo() {
        setOpaque(false);
        setContentAreaFilled(false);
        setForeground(Color.WHITE);
        setFocusPainted(false);
        setBorderPainted(false);
    }

    @Override
    protected void paintComponent(Graphics g) {
        Color c1,c2,c3;
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);

        ButtonModel m = getModel();

         Paint oldPaint = g2.getPaint();
        //botão precionado
        if (m.isArmed()){
           c2=color1.brighter();
           c1=color2.brighter();
           c3=borda;
        }else{
           c1=color1;
           c2=color2;
           c3=borda;
        }
        if (!m.isEnabled()){
           c2=color1.darker();
           c1=color2.darker();
           c3=borda;
         }
 
          RoundRectangle2D.Float r2d = new RoundRectangle2D.Float(
                    0,0,getWidth(),getHeight()-1,800,800);
          
            g2.clip(r2d);
            g2.setPaint(new GradientPaint(0.0f, 0.0f, c1,
                    0.0f, getHeight(), c2));
            g2.fillRect(0,0,getWidth(),getHeight());

            g2.setStroke(new BasicStroke(4f));
            g2.setPaint(new GradientPaint(0.0f, 0.0f, c3,
                    0.0f, getHeight(), c3));
            g2.drawRoundRect(0, 0, getWidth()-2 , getHeight() -2, 18, 18);

        g2.setPaint(oldPaint);
        super.paintComponent(g);
    }
}
